from txosc import osc
from Bases import BaseObject
from comm.osc.osc_io import oscIO

osc_conf = dict(connection_type='Unicast', 
                hostaddr='192.168.168.136', 
                sendport=18889, 
                recvport=18888)
client_addr = []
client_names = []

class OSCTest(BaseObject):
    def __init__(self, **kwargs):
        super(OSCTest, self).__init__(**kwargs)
        osc_conf.update({'_save_config_file':False})
        self.osc_io = oscIO(**osc_conf)
        self.osc_io._receiver.connect('raw_data', self.on_receiver_data)
        self.osc_io.do_connect()
        
    def on_receiver_data(self, **kwargs):
        data = kwargs.get('data')
        msg = osc._elementFromBinary(data)
        print 'decoded:  ', msg.address, msg.getValues()
        
if __name__ == '__main__':
    t = OSCTest()
